package com.example.game;
import android.util.Log;

public class Player{
    final static public int BUILDING_TYPE_COUNT = 20;
    String DATA_PATH= "";
//    boolean truth_bought = false;       //真相我已经买过了
    boolean flag_open_video_page = false;
    int news_count = 0;
    String[] building_name = {"招纳水军","雇佣小编","研发营销号视频自动生成器","制造营销热点","雇佣员工关注自己的营销号","建立宗教崇拜","营销号实现全频段阻塞","发展星际文明营销学","遗传学表征提升","向历史和未来中的生命体发布营销号内容"};
//    String[] builidng_background = {"\"\纯路人，有一说一，不吹不黑，确实"","\"欢迎在评论区和小编分享你的想法\"","\"震惊！不转不是中国人！难得一见的十张照片！\"","\"新合同\"","\"三个孩子的妈\"","建筑6背景","建筑7背景","建筑8背景","建筑9背景","建筑10背景"};
    String[] builidng_background = {"纯路人，有一说一，不吹不黑，确实","欢迎在评论区和小编分享你的想法","","把营销号送上热搜","招聘营销号评论业务员1名，工资2-8k元/ 月","起初，小编创造了营销号。编辑器里是空虚混沌。小编打字：“震惊！”于是就有了关注。————《圣经》","创造的营销号内容远远超过互联网原本的信息量，人们在浏览互联网信息时往往要同时浏览更多的营销号信息","开辟超空间航道，向外星生命传播营销号","提升低等级生命智慧，从而向他们传播营销号","“过去与未来交织，唯有营销号永恒长存”"};
    String[] tool_name = {"提高营销号内容质量","看一篇营销号文章？","看一个营销号的视频？","最后的真相"};
    String[] tool_background = {"每次宣传营销号可以获得+1关注","你可以增加20%的现有流量哦！","你每拥有一个水军，点击发布按钮获得的流量可以少量增加！","价格：10兆"};
    String[][] news = {
            {"你的营销号无人问津","几乎没有人知道你的营销号","没什么人喜欢看你的营销号","你的营销号视频什么弹幕也没有"},
            {"开始有一些人在你的营销号下面评论了","你有了一些忠实的粉丝","有些人喜欢看你的营销号"},
            {"你的营销号热闹了起来","你的营销号在各个平台都有不错的热度","你的大部分内容都有不少的浏览和转发","你的营销号视频有了少量的弹幕"},
            {"你的营销号炒上了热搜","营销号的评论区长得看不完","你的营销号被许多人所了解","你有了不少粉丝，但他们喜欢下次一定","有人在上课看你的营销号，导致挂科"},
            {"你的营销号内容有了一批最稳定的关注者","你的营销号发布的内容成了大家茶余饭后讨论的绝佳话题","你的员工每天都很辛苦地在评论区留言，以及关注和转发你的营销号内容","你的营销号过于优质，粉丝们都不愿意下次一定了"},
            {"营销号教堂在各地建成","信徒们向其他人转发营销号的福音","信众忙于在评论区里朝圣","不少工厂罢工，员工在家看营销号"},
            {"营销号内容已经远远超过人类产生以来产生信息的总和了","为了保存更多的营销号内容，你顺便升级了地球上的信息存储科技","你的营销号被存储于冰川之下，便于子孙后代反复观看"},
            {"我们的目标是将营销号传播向星辰大海！","半人马座的外星人也很喜欢在评论区里留言","很快，星际间的互联网也充满了营销号内容","有外星人通过收音机收听光年外的营销号电台，他们听得如痴如醉"},
            {"银河系的智慧生物数量极大地提升了","一个培养皿中的细菌产生了接近一个星球的关注人数","蜂群意识只能提供一个关注，因而被你强迫解散成数百亿的个体","夏天的夜晚，虫鸣、树影，仔细一听，它们在唱营销号的歌曲"},
            {"有限的过去，无限的未来，每个人都将在评论区与小编分享他们的看法","现在营销号《圣经》里说的都是事实的了","营销号的传播成为了宇宙规律的一部分,被载入教科书"}
    } ;



    //building_list 0~9 十种建筑，[0]为建筑的数量，[1]为建筑的当前价格
    //buidling_list 10  内容质量
    //building_list 11  是否观看完成视频（0或1）
    //building_list 12  点击button增加的个数(1% cps)
    //building_list 13  控制news播放
    //building_list 14  真相有没有买过


    long[] building_orignal_price =
            {
                    10,200,3000,40000*2,500000*2,
                    6000000*2,70000000*3/2,800000000L*3/2,9000000000L*3/2,100000000000L*3/2,
                    0,0,0,0,0,
                    0,0,0,0,0
            };
    double[] getBuilding_orignal_production =
            {
                    0.1,1,10,100,1000,
                    10000,100000,1000000,23333333,987654321,
                    0,0,0,0,0,
                    0,0,0,0,0
            };
    long cash;                                                          //记录当前存有的流量数
    long[][] building_list = new long[2][20];                                      //记录每种建筑的数量、下一个的价格
    int[] tool_list = new int[20];                                          //记录每个科技是否被研究过
    double production;                                                    //每0.05秒产生多少个
    int point = 0;                                                      //小数部分，每个代表0.05，每20个使cash+1
    String TAG = "Player_init_TAG";
    Player(){
        Log.d(TAG, "Player: checkpoint 0");
        //初始化
        point = 0;
        cash = 0;
        for (int i = 0; i < 20 ; i ++ ){
            building_list[0][i] = 0;                                    //building_list[0]记录第i个建筑的数量
            building_list[1][i] = building_orignal_price[i];            //building_list[1]记录第i个建筑下一次建造时的价格
            tool_list[i] = 0;
            production = 0;
            Log.d(TAG, "Player: checkpoint" + String.valueOf(i));
        }
    }
    public void new_record(){
        Log.d(TAG, "Player_making new record: checkpoint 0");
        //初始化
        point = 0;
        cash = 0;
        for (int i = 0; i < BUILDING_TYPE_COUNT ; i ++ ){
            building_list[0][i] = 0;
            building_list[1][i] = building_orignal_price[i];
            tool_list[i] = 0;
            production = 0;
     //       Log.d(TAG, "Player_making new record: checkpoint" + String.valueOf(i));
        }
    }

    public void refresh_production(){
        Log.d(TAG, "refresh_production: on start");
        point = 0;
        production = 0;
        for (int i = 0; i < BUILDING_TYPE_COUNT ; i ++ ){
            production += building_list[0][i] * getBuilding_orignal_production[i];  //以后这里还要补充一下tool导致的产量增长
        }
        Log.d(TAG, "refresh_production: " + String.valueOf(production));
    }
    public String convertLongToString (long inp){
        if(inp < 10000){
            return String.valueOf(inp);
        }
        String rtn = "";
        String[] d = {"万","亿","兆","京","垓"};
        long p = 0;
        int i = -1;
        while(inp >= 10000){
            i ++;
            p = inp % 10000;
            inp = inp / 10000;
        }
        p = p/100;
        //保留两位小数
        rtn = String.valueOf(inp) + "." ;
        if(p == 0){
            rtn = rtn + "00";
        }else if( p < 10){
            rtn = rtn + "0" + String.valueOf(p);
        }else{
            rtn = rtn + String.valueOf(p);
        }
        rtn = rtn + d[i];
        return rtn;
    }

//    public void check_next_news(){
//        if(building_list[0][13] == 0 && this.cash > 100 && this.cash < 1000){
//            building_list[0][13] = 1;
//        }else{
//            int count = -2;
//            long cash_tmp = this.cash;
//            while(cash_tmp > 0){
//                count ++;
//                cash_tmp = cash_tmp / 10;
//            }
//            if(count > 9){
//                count = 9;
//            }
//            if(building_list[0][13] < count) {
//                building_list[0][13] = count;
//            }
//            //0~100 : 0
//            //101~999 : 1
//            //1000~9999 : 2
//        }
//    }
    public void check_next_news(){
        int i = 0;
        while(this.building_list[0][i] > 0 && i < 10){
            i++;
        }
        i = i - 1;
        if(this.building_list[0][13] < i){
            this.building_list[0][13] = i;
        }

    }
}